const jsonServer = require("json-server");
const fsRoutes = require("fs-routes");

const app = jsonServer.create();

const output = fsRoutes.default("routes");

output.forEach((el) => {
  const m = require(el.path);
  Object.entries(m).forEach(([method,fn]) => {
    app[method](el.route, fn);
  });
});

module.exports = () => app;
